package com.szq.netty.client;

import com.szq.netty.codec.ObjDecoder;
import com.szq.netty.codec.ObjEncoder;
import com.szq.netty.domain.FileTransferProtocol;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * @ClassName: MyChannelInitializer
 * @Description:
 * @Author: szq
 * @Date: 2021-11-12 09:48:46
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel channel) {
        //对象传输处理
        channel.pipeline().addLast(new ObjDecoder(FileTransferProtocol.class));
        channel.pipeline().addLast(new ObjEncoder(FileTransferProtocol.class));
        channel.pipeline().addLast(new MyClientHandler());
    }
}
